//
//  AppDelegate.m
//  UI2_UILabel
//
//  Created by Marry W. on 16/1/21.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    // xcode7
    self.window.rootViewController = [[[UIViewController alloc] init] autorelease];
    
    // UILabel 标签
    // 1.创建+frame
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)];
    // 2.属性设置
    label.backgroundColor = [UIColor yellowColor];
    // 3.添加父视图
    [self.window addSubview:label];
    // 4.内存管理
    [label release];
    /***** label文字相关属性 ******/
    // 显示文字 text
    // 默认 左对齐/居中显示/文本黑色/行数为1/背景透明色
    label.text = @"这是一个label";
    // 文本颜色 textColor
    label.textColor = [UIColor purpleColor];
    // 文本对齐方式 textAlignment
    label.textAlignment = NSTextAlignmentCenter;
    // 断行模式(文本省略方式) lineBreakMode
    label.lineBreakMode = NSLineBreakByTruncatingMiddle;
    // 文本行数 numberOfLines
    // 默认为1 为0时行数不限
    label.numberOfLines = 0;
    // label自适应
    // 如果文本不足一行 宽高一起改变
    // 如果文本超过一行 只改变高
    // 一定要写在设置text之后 如果写在之前 label的size会置为0
//    [label sizeToFit];
    // 字体 font
    label.font = [UIFont systemFontOfSize:30];
    // 阴影 shadow
    label.shadowColor = [UIColor blueColor];
    // 阴影偏移量
    label.shadowOffset = CGSizeMake(10, 10);
    
    [_window release];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
